#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

extern char **environ;
//main函数有参数吗？有
//最有可以有几个？3个
//该参数是父进程传递给我们的
int main(int argc, char *argv[], char *env[])
{
	(void)argc;
	(void)argv;
	(void)env;

	for (int i = 0; environ[i]; i++)
	{
		printf("env[%d]-> %s\n", i, environ[i]);
	}


	//const char *who = getenv("USER");
	//if (who == NULL) return 1;

	//if (strcmp(who, "csq") == 0)
	//{
	//	printf("这是程序的正常执行逻辑\n");
	//}
	//else
	//{
	//	printf("Only csq!!!\n");
	//}



	//char *value = getenv("PATH");
	//if (value == NULL)
	//	return 1;
	//printf("PATH->%s\n", value);



//	for (int i = 0; env[i]; i++)
//	{
//		printf("env[%d]-> %s\n", i, env[i]);
//	}


	//if (argc != 2)
	//{
	//	printf("Usage: %s [-a|-b|-c]\n", argv[0]);
	//	return 1;
	//}
	//
	//const char *arg = argv[1];
	//if (strcmp(arg, "-a") == 0)
	//	printf("这是功能1\n");
	//else if (strcmp(arg, "-b") == 0)
	//	printf("这是功能2\n");
	//else if (strcmp(arg, "-c") == 0)
	//	printf("这是功能3\n");
	//else
	//	printf("Usage: %s [-a|-b|-c]\n", argv[0]);
//	for (int i = 0; i < argc; i++)
//	{
//		printf("argv[%d]: %s\n", i, argv[i]);
//	}
	return 0;
}
